package bist.believeinstep.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bist.believeinstep.domain.TourBooking;
import bist.believeinstep.util.Constant.BookingState;

public class TourBookingMapper implements RowMapper<TourBooking>{
	public TourBooking mapRow(ResultSet rs, int rowNum) throws SQLException{
		
		TourBooking tourBooking = new TourBooking();
		
		tourBooking.setId(rs.getInt("id"));
		tourBooking.setCode(rs.getString("tour_booking_code"));
		tourBooking.setTotalBooking(rs.getInt("total_booking"));
		tourBooking.setAdultBooking(rs.getInt("adult_booking"));
		tourBooking.setChildrenBooking(rs.getInt("children_booking"));
		tourBooking.setBabyBooking(rs.getInt("baby_booking"));
		tourBooking.setAdultPrice(rs.getBigDecimal("adult_price"));
		tourBooking.setChildrenPrice(rs.getBigDecimal("children_price"));
		tourBooking.setBabyPrice(rs.getBigDecimal("baby_price"));
		
		String state = rs.getString("state");
		tourBooking.setState(BookingState.create(state));
		
		tourBooking.setCreated(rs.getTimestamp("created_date"));
		tourBooking.setModified(rs.getTimestamp("modified_date"));
		tourBooking.setCreatedBy(rs.getString("created_by"));
		tourBooking.setModifiedBy(rs.getString("modified_by"));
		tourBooking.setBistUserId(rs.getInt("bist_users_id"));
		tourBooking.setBistTourId(rs.getInt("bist_tours_id"));
		tourBooking.setBistContactId(rs.getInt("bist_contacts_id"));
		
		return tourBooking;
	}

}
